package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class UserServiceImpl implements UserService{

    private static Map<Integer,String> paramMap=new HashMap<>();
    static {
        paramMap.put(1,"username");
        paramMap.put(2,"phone");
        paramMap.put(3,"email");
    }

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.selectList(null);
    }

    @Override
    public int checkUser(String param, Integer type) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(paramMap.get(type),param);
        return userMapper.selectCount(queryWrapper);
    }
}
